/**
 * Created by 余华杰 on 2015/5/22.
 */

/*
 * 进程状态
 * ready 就绪状态
 * run 运行状态
 */
var Status = ['ready','run'];

/*
 * 进程生命周期
 */
var Life =[1,2,3,4,5];

/*
 * 进程PCB构造函数
 * @param pid 进程标示符
 * @param status 进程状态
 * @param priority 进程优先级
 * @param next 进程队列指针，指向下一个PCB
 * @param life 进程生命周期
 */
function Process(pid,status,priority,next,life){
    this.pid=pid;
    this.status=status;
    this.priority=priority;
    this.next=next;
    this.life=life;
}


Process.prototype.create=function(parent){


    var $pid=$("<span></span>")
        .attr("id","pid")
        .text(this.pid);
    $pid=$("<div></div>").append("pid=",$pid);

    var $status=$("<span></span>")
        .attr("id","status")
        .text(this.status);
    $status=$("<div></div>").append("status=",$status);

    var $priority=$("<span></span>")
        .attr("id","priority")
        .text(this.priority);
    $priority=$("<div></div>").append("priority=",$priority);

    var $next=$("<span></span>")
        .attr("id","next")
        .text(this.next==null?0:this.next.pid);
    $next=$("<div></div>").append("next=",$next);

    var $life=$("<span></span>")
        .attr("id","life")
        .text(this.life);
    $life=$("<div></div>").append("life=",$life);

    var $PCB=$("<div></div>")
        .addClass("cms-priority")
        .append($pid,$status,$priority,$next,$life);
    parent.append($PCB);
}

Process.prototype.decLife=function(){
    this.life=this.life-1;
}
